import React, { Component } from 'react'
import img1 from '../asssets/img/log.png'
import { Toast } from 'antd-mobile';

export default class login extends Component {
  constructor() {
    super();
    this.state = {
      name: '',
      pass: '',
    }
  }
  getInputVal(type, e) {
    this.setState({
      [type]: e.target.value
    })
  }
  login() {
    if(this.state.name && this.state.pass) {
      // axios  发请求后将数据存入localStorage，主要是token
    }else {
      Toast.info('请填写完整！', 1);
    }
  }
  render() {
    return (
      <div>
        <img src={img1} alt="" />
        <br/>
        <input placeholder="name" value={this.state.name}
          onChange={(e)=>this.getInputVal('name' , e)}></input>
        <input placeholder="pass" value={this.state.pass}
          onChange={(e)=>this.getInputVal('pass' , e)}></input>
        <button onClick={()=>this.login()}>登录</button>
      </div>
    )
  }
}
